package com.itheima.tliaswebmanagement.mapper;

import com.github.pagehelper.Page;
import com.itheima.tliaswebmanagement.pojo.Emp;
import com.itheima.tliaswebmanagement.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

//    @Select("select e.*,d.name as dept_name from emp e left join dept d on e.dept_id= d.id limit #{beginIndex},#{pageSize}")
//    public List<Emp> list(Integer beginIndex,Integer pageSize);
//
//
//    @Select("select count(*) from emp e left join dept d on e.dept_id= d.id;")
//    public Long count();

//    @Select("select e.*,d.name as dept_name from emp e left join dept d on e.dept_id= d.id")
//    public Page<Emp> list();

    public Page<Emp> list(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void save(Emp emp);

    void deleteByIds(List<Integer> ids);

    void update(Emp emp);
//    @MapKey("pos")
    List<Map<String, Object>> countJobData();

//    @MapKey("name")
    List<Map<String, Object>> countGenderData();

    List<Emp> findAll();

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp login(Emp emp);
}
